Giter Site home page Giter Site logo

dbentry's People

Contributors

lifeng-liang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dbentry's Issues

相对路径的配置

我在使用mdb数据库,可以使用相对路径吗?或者在软件中利用字符串来配置连接。

Non Dot Net Dll file in same folder, gives Error

Dear Sir,
I am using Non Dot Net dll file in .net Application.
Due to this, it gives typeinitialisation error.
after digging into problem, found that problem occurs due to SearchAssemblies method in SimpleContainer.cs.
i changed the code a little bit and it started functioning.
'try
{
var assembly = Assembly.LoadFrom(fn);
assemblies.Add(assembly);
}
catch (Exception) { }'
let me know, if this is the correct way?
or any other solution on the same.
regards
Shailesh

error about Transaction

I have config AutoCreateTable/FixScheme,after 'createtable' method executed in 'DbEntry.UsingTransaction',it will throw error.

Any() Max() 等

“System.NotImplementedException”类型的异常在 Leafing.Data.dll 中发生,但未在用户代码中进行处理

其他信息: 未实现该方法或操作。

请问要怎么更新懒加载字段呢?

因为历史原因,有表主键不是id的情况, 定义为 IDbObject。设置了某字段为LazyLoad

给该字段赋值时 字段名.value=xxx,会报 未将对象设置引用到对象实例 的错误。调试 该字段当时为null

请问要怎么更新懒加载字段呢? 谢谢。

请问关系必须是成对出现的吗?删除hasmany的list对象是否有简单的方法呢?

如下 1对多 关系 是否必须2个类中都定义呢?

//user.cs
 public class User : DbObjectModel<User >
    {
        [OrderBy("Id")]
        public HasMany<Book> Books { get; private set; }
    }

//book.cs
 public class Book: DbObjectModel<Book>
    {
        public BelongsTo<User, long> UserId { get; set; }
        [Exclude]
        public  User User
        {
            get { return UserId .Value; }
            set { UserId Value = value; }
        }
    }

请问如何快速的删除 某个user下的 books呢?

我尝试

Leafing.Data.DbEntry.From<Book>().Where(c => c.UserId == 1).Delete();
//or
Leafing.Data.DbEntry.DeleteBy<Book>(c => c.UserId == 1);
//or
Book.DeleteBy(c => c.UserId == 1);

均报错。

运算符“==”无法应用于“BelongsTo<User, long>”和“int”类型的操作

手册中,相关的测试用例中 关于这部分 也都看了。 没找到 相似的代码。 还请解答下。 谢谢。

System.Data.SQLite.dll 目前无法正常通过测试

对于GIT上最新版本, 应用于System.Data.SQLite.dll不能正常运行。
配置文件如下:


<Leafing.Settings>
    <add key="AutoCreateTable" value="true"/>
    <add key="AutoScheme" value="CreateTable" />
    <add key="DataBase" value="@SQLite : @~Test.db;" />
    <add key="DbProviderFactory" value="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.99.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</Leafing.Settings>

此配置不能通过测试, 对于4.2版本,能正常运行,请修复。

OnUpdating 执行顺序问题

看源码 Leafing.Data\Model\Saver\SimpleObjectSaver.cs (47)
发现 OnUpdating 是在 Composer.GetUpdateStatement(obj, iwc) 之后,
但是我的理解 OnInserting OnUpdating 更准确的描述为 OnBeforeInserte OnBeforeUpdate,
比如以下需求

protected override void OnInserting(){
   LastEditTime = DateTime.Now;
   base.OnInserting();
 }
 protected override void OnUpdating() {
   LastEditTime = DateTime.Now;
   base.OnUpdating();
 }

结果导致 OnUpdating 中的赋值失效, OnUpdating 变成 OnUpdated 了
OnInserting 没有此问题.

修改源码 Leafing.Data\Model\Saver\DbModelSaver.cs(26) 添加
o.RaiseUpdating();
就没有此问题

ExecuteNonQuery有情况会出现数组越界

重现条件如下:
1、传进去的SQL语句中包含字符串
2、该字符串中同时包含换行与英文问号
举例:
insert into table1(field1) values('sometext?
Sometex')

经查,问题原因在于GetSqlStatement中使用的正则表达式"'.*'|\?"是默认的多行模式,导致字符串中含有换行时可以匹配到问号,从而进入参数配对环节,最终对参数数组的访问就会越界

DataSource 组件bug2

ObjectDeletedText、ObjectUpdatedText 等属性中的变量{0} 的值无法进行配置,默认模型的类名

使用BelongsTo时候,ParentId奇怪的被更新了

`using Leafing.Data;
using Leafing.Data.Definition;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace myTest
{
class Program
{
static void Main(string[] args)
{

        init1();

        init2();

        Console.ReadLine();
    }

    static void init1()
    {
        DbEntry.DropAndCreate(typeof(Temp_SystemDept));
        var z = new Temp_SystemDept { DeptName = "总公司" };
        z.ParentDept.Value = null;
        z.Save();
        Console.WriteLine(Temp_SystemDept.FindById(1).ToString());

        var z1 = new Temp_SystemDept { DeptName = "长沙分公司" };
        z1.ParentDept.Value = z;
        z1.Save();
        Console.WriteLine(Temp_SystemDept.FindById(1).ToString());

        var z2 = new Temp_SystemDept { DeptName = "上海分公司" };
        z2.ParentDept.Value = z;
        z2.Save();
        Console.WriteLine(Temp_SystemDept.FindById(1).ToString());

        Console.WriteLine("done");
    }
    static void init2()
    {
        DbEntry.DropAndCreate(typeof(Temp_SystemDeptTree));
        var z = new Temp_SystemDeptTree { DeptName = "总公司", Parent = null };
        z.Save();
        Console.WriteLine(Temp_SystemDeptTree.FindById(1).ToString());


        new Temp_SystemDeptTree { DeptName = "长沙分公司", Parent = z }.Save();
        Console.WriteLine(Temp_SystemDeptTree.FindById(1).ToString());


        new Temp_SystemDeptTree { DeptName = "上海分公司", Parent = z }.Save();
        Console.WriteLine(Temp_SystemDeptTree.FindById(1).ToString());

        Console.WriteLine("done");
    }
}

public class Temp_SystemDept : DbObjectModel<Temp_SystemDept, int>
{

    [Length(30)]
    public string DeptName { get; set; }

    [DbColumn("ParentDeptId")]
    public BelongsTo<Temp_SystemDept, int> ParentDept { get; set; }

    public HasMany<Temp_SystemDept> ChildDepts { get; set; }

}

public class Temp_SystemDeptTree : DbObjectModelAsTree<Temp_SystemDeptTree, int>
{

    [Length(30)]
    public string DeptName { get; set; }
}

}
`

Console结果

{ Id = 1, DeptName = 总公司, ParentDeptId = }
{ Id = 1, DeptName = 总公司, ParentDeptId = }
{ Id = 1, DeptName = 总公司, ParentDeptId = 2 } ———————被更新了
done
{ Id = 1, DeptName = 总公司, BelongsTo_Id = }
{ Id = 1, DeptName = 总公司, BelongsTo_Id = }
{ Id = 1, DeptName = 总公司, BelongsTo_Id = 2 } ——————被更新了
done

DataSource 组件bug

1、提交表单DataSource校验未通过时,表单中控件的class样式表被替换成为ErrInput,原有样式丢失
2、DataSource 提交成功(修改、删除、更新)给出提示后,将表单中控件的原有样式清空,应保留原有样式

请问继承自 xxxx 的模型, 如果想实现部分更新应该怎么写呢? 谢谢。

仔细看了下面的测试用例。

AssertSql(@"UPDATE [Mkey2] SET [Age]=@Age_0 WHERE ([FirstName] = @FirstName_1) AND ([LastName] = @LastName_2);

但是我自己的代码实际用行时,就会更新所有字段。

using Leafing.Data.Definition;

namespace test
public class Case : IDbObject
{
        [DbKey, DbColumn("case_id")]
        public int Id { get; set; }

        public int Year { get; set; }

        public string Number { get; set; }

        public string Content { get; set; }
//... 其他字段
        public string OtherContent { get; set; }
}


 var p = new Case
            {
                Year = year,
                Number = number,
                Id = id
            };
 DbEntry.Update(p);
/*执行时,打印的 sql 语句 会将 Case 的所有字段全部进行更新,造成其他字段属性都丢了。
请问应该如何只更新部分字段呢?*/

谢谢大家,请多多指导。

HasAndBelongsToMany 属性的BUG

描述

  • 两个Model间用HasAndBelongsToMany进行关联,生成的关联表字段会以第一个获取到的字段类型生成关联。
  • 比如:mTask ID 类型为 GUID, mUser ID类型为 long,则生成的R_mTask_mUser 里的 mTask_IdmUser_Id 均为GUID类型。

代码

mUser

public class mUser : DbObjectModel<mUser>
{

        /// <summary>
        /// 参与过的任务
        /// </summary>
        [HasAndBelongsToMany]
        public IList<mTask> join_tasks { get; private set; }
//....
//some code
//....
}

mTask

public class mTask : DbObjectModel<mTask, Guid>
{

        /// <summary>
        /// 参与成员
        /// </summary>
        [HasAndBelongsToMany]
        public IList<mUser> members { get; private set; }
//....
//some code
//....
}

DataSource控制样式BUG

default

如上图,出现2个问题
1、表单控件原有css被替换,导致样式与其他控件不一致
2、NoticeMessage 控件使用了CssWarning值,次值也在录入错误的控件中被使用,造成2中性质的控件样式一致

Fix - CoreException: Can not find [Leafing.Core.Logging.ILogRecorder] name [Debug]

Logger is created before SimpleContainer create.

FIX:

SimpleContainer.cs

remove using Leafing.Core.Logging;

replace:
try {
var assembly = Assembly.LoadFrom(fn);
assemblies.Add(assembly);
} catch (Exception ex) {
Logger.System.Warn(ex);
}

with:
try {
var assembly = Assembly.LoadFrom(fn);
assemblies.Add(assembly);
} catch (Exception ex) {
throw ex;
}

Act As Tree Bug

HI ALL:
使用ActAsTree功能时, 存在HasMany的情况下,数据库表UxFile的BelongTo_ID不完全正确。子对象正常,父对象此值给出了一个错误值。 请修复此情况。
` [DbContext("JbCtx")]
public class UxFile : DbObjectModelAsTree
{
public string Name { get; set; }

    public HasMany<MyJobStep> MyJobStep { get;private set; } 
}

[DbContext("JbCtx")]
public class MyJobStep : DbObjectModel<MyJobStep>
{
    public int IdAny { get; set; }

    public BelongsTo<UxFile> _uxFile { get; set; }

    [Exclude]
    public UxFile UxFile
    {
        get { return _uxFile.Value; }
        set { _uxFile.Value = value; }
    }
}

class TestHelper
{
    private static void DoTest()
    {
        var f2 = new UxFile()
        {
            Name = "F2"
        };
        var f3 = new UxFile()
        {
            Name = "F3"
        };
        var fi = new UxFile()
        {
            Name = "F1"
        };
        fi.Children.Add(f2);
        fi.Children.Add(f3);

        var mm = new MyJobStep();
        mm.UxFile = fi;
        mm.Save();
    }
}

`

DataSource.NoticeMessageID 指定的label控件的css被修改

设置了DataSource的CssWarning后(由多个css组合),NoticeMessageID 指定的label控件的css也被完全替换成由多个css组合的CssWarning,导致label样式混乱

或可考虑在任何情况下表单里的空间都显示CssCommon设定的css,要提示信息时在 CssCommon 属性基础上增加获清除 Warning

DataSource 表单校验提醒bug

DataSource 的 NoticeMessageID 设置为 Label 后,表单验证不通过时报错。

NoticeLabelAdapter.cs 中的 private List _msgList 改成 private List _msgList = new List(); 既可

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.