コード例 #1
0
        /// <summary>
        /// Creates the entity connection with wrappers.
        /// </summary>
        /// <param name="entityConnectionString">The original entity connection string. This may also be a single word, e.g., "MyEntities", in which case it is translated into "name=MyEntities" and looked up in the application configuration.</param>
        /// <param name="wrapperProviders">List for wrapper providers.</param>
        /// <returns>EntityConnection object which is based on a chain of providers.</returns>
        public static EntityConnection CreateEntityConnectionWithWrappers(string entityConnectionString, params string[] wrapperProviders)
        {
            // If there is only a single word in the connection string, treat it as the value for Name.
            if (!entityConnectionString.Contains('='))
                entityConnectionString = "name=" + entityConnectionString;

            EntityConnectionStringBuilder ecsb = new EntityConnectionStringBuilder(entityConnectionString);

            // if connection string is name=EntryName, look up entry in the config file and parse it
            if (!String.IsNullOrEmpty(ecsb.Name))
            {
                var connStr = ConfigurationManager.ConnectionStrings[ecsb.Name];
                if (connStr == null)
                {
                    throw new ArgumentException("Specified named connection string '" + ecsb.Name + "' was not found in the configuration file.");
                }

                ecsb.ConnectionString = connStr.ConnectionString;
            }

            var workspace = metadataWorkspaceMemoizer.GetOrAdd(ecsb.ConnectionString, _ => CreateWrappedMetadataWorkspace(ecsb.Metadata, wrapperProviders));
            var storeConnection = DbProviderFactories.GetFactory(ecsb.Provider).CreateConnection();
            storeConnection.ConnectionString = ecsb.ProviderConnectionString;
            var newEntityConnection = new EntityConnection(workspace, DbConnectionWrapper.WrapConnection(storeConnection, wrapperProviders));
            return newEntityConnection;
        }
コード例 #2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="EntityTableDataLoader" /> class.
 /// </summary>
 /// <param name="connection"> The connection towards the database. </param>
 /// <param name="table"> The metadata of the table. </param>
 public EntityTableDataLoader(EntityConnection connection, TableDescription table)
     : base(table)
 {
     this.connection = connection;
     this.workspace = connection.GetMetadataWorkspace();
     this.entitySet = MetadataWorkspaceHelper
         .GetEntityContainer(this.workspace)
         .GetEntitySetByName(table.Name, true);
 }
コード例 #3
0
        /// <summary>
        ///     Ensures that a connection is established towards to appropriate database and 
        ///     creates a <see cref="EntityTableDataLoader" /> instance for the specified
        ///     table.
        /// </summary>
        /// <param name="table"> 
        ///     The metadata of the table.
        /// </param>
        /// <returns>
        ///     The <see cref="EntityTableDataLoader" /> instance for the table.
        /// </returns>
        public ITableDataLoader CreateTableDataLoader(TableDescription table)
        {
            if (this.connection == null)
            {
                this.connection = this.connectionFactory.Invoke();
                this.connection.Open();
            }

            return new EntityTableDataLoader(this.connection, table);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: yingfangdu/SQLiteNet
      /// <summary>
      /// Attempts to obtain the underlying store connection
      /// (a <see cref="DbConnection" />) from the specified
      /// <see cref="EntityConnection" />.
      /// </summary>
      /// <param name="entityConnection">
      /// The <see cref="EntityConnection" /> to use.
      /// </param>
      /// <returns>
      /// The <see cref="DbConnection" /> -OR- null if it
      /// cannot be determined.
      /// </returns>
      private static DbConnection GetStoreConnection(
          EntityConnection entityConnection
          )
      {
          //
          // NOTE: No entity connection, no store connection.
          //
          if (entityConnection == null)
              return null;

          //
          // HACK: We need the underlying store connection and
          //       the legacy versions of the .NET Framework do
          //       not expose it; therefore, attempt to grab it
          //       by force.
          //
          FieldInfo fieldInfo = typeof(EntityConnection).GetField(
              "_storeConnection", BindingFlags.Instance |
              BindingFlags.NonPublic);

          //
          // NOTE: If the field is not found, just return null.
          //
          if (fieldInfo == null)
              return null;

          return fieldInfo.GetValue(entityConnection) as DbConnection;
      }
コード例 #5
0
 /// <summary>
 /// Initialize a new StudentContext object.
 /// </summary>
 public StudentContext(EntityConnection connection) : base(connection, "StudentContext")
 {
     this.ContextOptions.LazyLoadingEnabled = true;
     OnContextCreated();
 }
コード例 #6
0
 /// <summary>
 /// Initialize a new Entities object.
 /// </summary>
 public Entities(EntityConnection connection) : base(connection, "Entities")
 {
     this.ContextOptions.LazyLoadingEnabled = true;
     OnContextCreated();
 }
コード例 #7
0
 internal DbContextTransaction(EntityConnection connection, IsolationLevel isolationLevel)
 {
     this._connection = connection;
     this.EnsureOpenConnection();
     this._entityTransaction = this._connection.BeginTransaction(isolationLevel);
 }
コード例 #8
0
 /// <summary>
 /// Initialize a new ApplicationDataObjectContext object.
 /// </summary>
 public ApplicationDataObjectContext(EntityConnection connection) : base(connection, "ApplicationDataObjectContext")
 {
     OnContextCreated();
 }
コード例 #9
0
        private static EntityConnection CreateInspectedFakeEntityConnection(string entityConnectionString, IResultSetComposer resultSetComposer, bool createFake, IDataLoader dataLoader)
        {
            EntityConnectionStringBuilder connectionString = new EntityConnectionStringBuilder(entityConnectionString);

            if (!string.IsNullOrEmpty(connectionString.Name))
            {
                string resolvedConnectionString = ConfigurationManager.ConnectionStrings[connectionString.Name].ConnectionString;
                connectionString = new EntityConnectionStringBuilder(resolvedConnectionString);
            }

            List<XElement> csdl = new List<XElement>();
            List<XElement> ssdl = new List<XElement>();
            List<XElement> msl = new List<XElement>();

            MetadataWorkspaceHelper.ParseMetadata(connectionString.Metadata, csdl, ssdl, msl);

            foreach (XElement ssdlFile in ssdl)
            {
                XAttribute providerAttribute = ssdlFile.Attribute("Provider");
                XAttribute providerManifestTokenAttribute = ssdlFile.Attribute("ProviderManifestToken");

                if (createFake)
                {
                    EffortProviderConfiguration.VerifyProvider();
                    UniversalStorageSchemaModifier.Instance.Modify(ssdlFile, new EffortProviderInformation());
                }

                string oldProviderInvariantName = providerAttribute.Value;
                string oldProviderManifestToken = providerManifestTokenAttribute.Value;

                providerAttribute.Value = DataReaderInspectorProviderConfiguration.ProviderInvariantName;
                providerManifestTokenAttribute.Value = string.Format("{0};{1}", oldProviderInvariantName, oldProviderManifestToken);
            }

            MetadataWorkspace convertedWorkspace = MetadataWorkspaceHelper.CreateMetadataWorkspace(csdl, ssdl, msl);

            DbConnection storeConnection = null;

            if (createFake)
            {
                storeConnection = Effort.DbConnectionFactory.CreateTransient(dataLoader);
            }
            else
            {
                storeConnection = ProviderHelper.CreateConnection(connectionString.Provider);
                storeConnection.ConnectionString = connectionString.ProviderConnectionString;
            }
            
            DbConnectionWrapper inspectorConnection = new DataReaderInspectorConnection(resultSetComposer);
            inspectorConnection.WrappedConnection = storeConnection;

#if !EFOLD
            EntityConnection entityConnection =
                new EntityConnection(convertedWorkspace, inspectorConnection, true);
#else
            EntityConnection entityConnection = 
                new EntityConnection(convertedWorkspace, inspectorConnection);

            FieldInfo owned = 
                typeof(EntityConnection)
                .GetField(
                    "_userOwnsStoreConnection", 
                    BindingFlags.Instance | BindingFlags.NonPublic);

            owned.SetValue(entityConnection, false);
#endif

            if (createFake)
            {
                using (ObjectContext objectContext = new ObjectContext(entityConnection))
                {
                    if (!objectContext.DatabaseExists())
                    {
                        objectContext.CreateDatabase();
                    }
                }
            }

            return entityConnection;
        }
コード例 #10
0
 public void EntityConnectionFactory_CreateTransientEntityConnection()
 {
     EntityConnection connection = EntityConnectionFactory.CreateTransient(NorthwindObjectContext.DefaultConnectionString);
 }
コード例 #11
0
 /// <summary>
 /// Initialize a new NorthwindEntities1 object.
 /// </summary>
 public NorthwindEntities1(EntityConnection connection) : base(connection, "NorthwindEntities1")
 {
     this.ContextOptions.LazyLoadingEnabled = true;
     OnContextCreated();
 }
コード例 #12
0
 public AdepUcbEntities(EntityConnection connection)
     : base(connection, ContainerName)
 {
     this.ContextOptions.LazyLoadingEnabled = false;
 }
コード例 #13
0
 public DataTemplateEntities(EntityConnection connection) : base(connection, "DataTemplateEntities")
 {
     base.ContextOptions.LazyLoadingEnabled = true;
 }
コード例 #14
0
 /// <summary>
 /// Initialize a new PackTrackingDatabaseEntities1 object.
 /// </summary>
 public PackTrackingDatabaseEntities1(EntityConnection connection) : base(connection, "PackTrackingDatabaseEntities1")
 {
     this.ContextOptions.LazyLoadingEnabled = true;
     OnContextCreated();
 }
コード例 #15
0
 /// <summary>
 /// 初始化新的 AdventureWorks2012Entities 物件。
 /// </summary>
 public AdventureWorks2012Entities(EntityConnection connection) : base(connection, "AdventureWorks2012Entities")
 {
     this.ContextOptions.LazyLoadingEnabled = true;
     OnContextCreated();
 }
コード例 #16
0
        public IActionResult GetPrescriptionbyVisit(int visitId)
        {
            EntityConnection            con   = new EntityConnection("tbl_diagnosis");
            Dictionary <string, string> pairs = new Dictionary <string, string>
            {
                { "visitId", visitId + "" }
            };

            Dictionary <string, object> result = con.GetPrescriptionVisit(visitId);


            //Check if the parent method returns a record
            if (result.Count > 0)
            {
                result.TryGetValue("otherDrugs", out newobj);
                result.TryGetValue("drugs", out obj);

                string otherDrugs = newobj.ToString();
                string newdrug    = obj.ToString();

                result.Remove("drugs");
                result.Remove("otherDrugs");

                //check if the drug list is empty
                if (newdrug.Trim() != "")
                {
                    string[] drugs = newdrug.Split(',');

                    string[] orQueries = drugs.Select(drugId => "itbId =" + drugId).ToArray(); // [itbId=3, itbId=5]

                    if (orQueries != null)
                    {
                        var drugDetails = con.DrugDetails(orQueries);
                        result.Add("drugs", drugDetails);
                    }
                }
                else
                {
                    result.Add("drugs", new string[0]);
                }

                //check if other drugs is empty
                if (otherDrugs.Trim() != "")
                {
                    string[] newOtherDrugs = otherDrugs.Split('|');
                    result.Add("otherDrugs", newOtherDrugs);
                }
                else
                {
                    result.Add("otherDrugs", new string[0]);
                }

                obj = new { data = result };
                return(Ok(obj));
            }
            else
            {
                string[] arr = new string[0];
                return(Ok(arr));
            }
        }
コード例 #17
0
 internal RepositoryBase(EntityConnection connection, ILog log, string itemType)
 {
     Connection    = connection;
     Log           = log;
     this.itemType = itemType;
 }
コード例 #18
0
ファイル: agent.Designer.cs プロジェクト: tttt080/OSMSClient
 /// <summary>
 /// 初始化新的 testEntities_agent 对象。
 /// </summary>
 public testEntities_agent(EntityConnection connection) : base(connection, "testEntities_agent")
 {
     this.ContextOptions.LazyLoadingEnabled = true;
     OnContextCreated();
 }
コード例 #19
0
 public OilDataManageEntities(EntityConnection connection)
     : base(connection, ContainerName)
 {
     Initialize();
 }
コード例 #20
0
        public ActionResult CreateStavka(int ID, StavkaFaktureTable newStavkaFakture)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var    ukupno     = newStavkaFakture.cena * newStavkaFakture.kolicina;
            int    redniBr    = 0;
            int    redniBrmax = 0;
            string sqlMax     = "";

            //broj redova u tabeli Stavke
            string sqlCount = @"SELECT COUNT(*) FROM StavkaFaktureTable";
            int    count    = _db.Database.SqlQuery <int>(sqlCount).Single();

            if (count != 0)
            {
                sqlMax     = @"SELECT MAX(redniBr) FROM StavkaFaktureTable";
                redniBrmax = _db.Database.SqlQuery <int>(sqlMax).Single();
                redniBr    = redniBrmax + 1; //redni broj postavljano za 1 veci od max rednog broja u tabeli
            }

            _db.StavkaFaktureTables.Add(new StavkaFaktureTable
            {
                redniBr   = redniBr,
                fakturaID = ID,
                kolicina  = newStavkaFakture.kolicina,
                cena      = newStavkaFakture.cena,
                ukupno    = ukupno
            });

            _db.SaveChanges();

            //kada se doda nova stavka treba vrednost ukupno_stavki u tabeli Faktura da promenimo i da dodamo tu stavku u listuStavki
            int countSF = 0;

            string esqlQuery = "";
            int    counter   = 0;

            using (EntityConnection conn = new EntityConnection("name=FaktureDBEntities"))
            {
                conn.Open();

                esqlQuery = @"SELECT VALUE sf FROM FaktureDBEntities.StavkaFaktureTables as sf where sf.fakturaID = @id";

                using (EntityCommand cmd = new EntityCommand(esqlQuery, conn))
                {
                    //kreiramo parametar za parametarski upit
                    EntityParameter param1 = new EntityParameter();
                    param1.ParameterName = "id";
                    param1.Value         = ID;

                    cmd.Parameters.Add(param1);

                    using (DbDataReader rdr = cmd.ExecuteReader(CommandBehavior.SequentialAccess))

                    {
                        while (rdr.Read())
                        {
                            //broj redova u tabeli Stavki za dati fakturaID
                            counter++;
                        }
                    }
                }
            }

            countSF = counter;

            var faktura = _db.FakturaTables.Find(ID);

            var result = _db.FakturaTables.SingleOrDefault(f => f.fakturaID == faktura.fakturaID);

            if (!ModelState.IsValid)
            {
                return(View(faktura));
            }

            if (result != null)
            {
                result.ukupno_stavki = countSF;
                _db.SaveChanges();
            }

            faktura.StavkaFaktureTables.Add(newStavkaFakture);

            return(RedirectToAction("Index"));
        }
コード例 #21
0
        /// <summary>
        ///     A Database extension method that gets entity transaction.
        /// </summary>
        /// <param name="entityConnection">The @this to act on.</param>
        /// <returns>The entity transaction.</returns>
        public static EntityTransaction GetEntityTransaction(this EntityConnection entityConnection)
        {
            var entityTransaction = entityConnection.GetType().GetField("_currentTransaction", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(entityConnection);

            return((EntityTransaction)entityTransaction);
        }
コード例 #22
0
 /// <summary>
 /// Initialize a new WD_teszt_modelContainer object.
 /// </summary>
 public WD_teszt_modelContainer(EntityConnection connection) : base(connection, "WD_teszt_modelContainer")
 {
     this.ContextOptions.LazyLoadingEnabled = true;
     OnContextCreated();
 }
コード例 #23
0
 /// <summary>
 /// Initialize a new EFRecipesEntities object.
 /// </summary>
 public EFRecipesEntities(EntityConnection connection) : base(connection, "EFRecipesEntities")
 {
     OnContextCreated();
 }
コード例 #24
0
 internal DbContextTransaction(EntityConnection connection)
 {
     this._connection = connection;
     this.EnsureOpenConnection();
     this._entityTransaction = this._connection.BeginTransaction();
 }
コード例 #25
0
 public EntityFrameworkHelper(string ConnectionString)
 {
     cn = new EntityConnection(ConnectionString);
 }
コード例 #26
0
 internal DbContextTransaction(EntityTransaction transaction)
 {
     this._connection = transaction.Connection;
     this.EnsureOpenConnection();
     this._entityTransaction = transaction;
 }
コード例 #27
0
 /// <summary>
 /// Initialize a new L24CMEntities object.
 /// </summary>
 public L24CMEntities(EntityConnection connection) : base(connection, "L24CMEntities")
 {
     OnContextCreated();
 }
コード例 #28
0
 /// <summary>
 /// Initialize a new sliceofpieEntities2 object.
 /// </summary>
 public sliceofpieEntities2(EntityConnection connection) : base(connection, "sliceofpieEntities2")
 {
     this.ContextOptions.LazyLoadingEnabled = true;
     OnContextCreated();
 }
コード例 #29
0
ファイル: MView.cs プロジェクト: janbrogger/EdmGen06
 /// <summary>
 /// 新しい SchemaInformation オブジェクトを初期化します。
 /// </summary>
 public SchemaInformation(EntityConnection connection)
     : base(connection, "SchemaInformation")
 {
     this.ContextOptions.LazyLoadingEnabled = true;
     this.OnContextCreated();
 }
コード例 #30
0
 public UFCEntities(EntityConnection connection)
     : base(connection, ContainerName)
 {
     this.ContextOptions.LazyLoadingEnabled = true;
 }
コード例 #31
0
        /// <summary>
        ///     Creates a new EntityConnection object and initializes its underlying database.
        /// </summary>
        /// <param name="metadata"> The metadata of the database. </param>
        /// <param name="connection"> The wrapped connection object. </param>
        /// <returns> The EntityConnection object. </returns>
        private static EntityConnection CreateEntityConnection(
            MetadataWorkspace metadata,
            DbConnection connection)
        {
            #if !EFOLD
            EntityConnection entityConnection =
                new EntityConnection(metadata, connection, true);
            #else
            EntityConnection entityConnection =
                new EntityConnection(metadata, connection);

            FieldInfo owned =
                typeof(EntityConnection)
                .GetField(
                    "_userOwnsStoreConnection",
                    BindingFlags.Instance | BindingFlags.NonPublic);

            owned.SetValue(entityConnection, false);
            #endif

            using (ObjectContext objectContext = new ObjectContext(entityConnection))
            {
                if (!objectContext.DatabaseExists())
                {
                    objectContext.CreateDatabase();
                }
            }

            return entityConnection;
        }
コード例 #32
0
 /// <summary>
 /// Initialize a new testEntities object.
 /// </summary>
 public testEntities(EntityConnection connection) : base(connection, "testEntities")
 {
     OnContextCreated();
 }
コード例 #33
0
 /// <summary>
 /// Initialize a new PoslovniKlubEntities object.
 /// </summary>
 public PoslovniKlubEntities(EntityConnection connection) : base(connection, "PoslovniKlubEntities")
 {
     this.ContextOptions.LazyLoadingEnabled = true;
     OnContextCreated();
 }
コード例 #34
0
        /// <summary>
        /// 是否查询直接下属
        /// </summary>
        /// <param name="EmpLoyeeID"></param>
        /// <param name="IsFirst"></param>
        /// <returns></returns>
        public List <Sys_Employee> GetMyManagerEmpLoyee(int?EmpLoyeeID, bool IsFirst)
        {
            HHL_WeddingEntities ObjWeddingDataContext = new HHL_WeddingEntities();

            using (EntityConnection ObjEntityconn = new EntityConnection("name=HHL_WeddingEntities"))
            {
                List <int>    ObjKeyList     = new List <int>();
                ObjectContext ObjDataContext = new ObjectContext(ObjEntityconn);

                //我主管的部门
                var MyDepartmentList = ObjWeddingDataContext.Sys_Department.Where(C => C.DepartmentManager == EmpLoyeeID);

                //我所在的部门
                var MineEmployeeModel = this.GetByID(EmpLoyeeID);
                var MyDepartment      = ObjWeddingDataContext.Sys_Department.FirstOrDefault(C => C.DepartmentID == MineEmployeeModel.DepartmentID);
                List <Sys_Department> ObjDepartmentList = new List <Sys_Department>();

                if (IsFirst)
                {
                    //先取得我主管的部门
                    foreach (var ObjDepartment in MyDepartmentList)
                    {
                        ObjDepartmentList.AddRange(ObjDataContext.CreateQuery <Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.SortOrder  =   '" + ObjDepartment.SortOrder + "'").ToList <Sys_Department>());
                    }
                    //取得部门主管 和我直接领导的部门

                    //部门主管
                    List <int> ObjManagerList = new List <int>();
                    foreach (var Objitem in ObjDepartmentList)
                    {
                        ObjKeyList.Add(Objitem.DepartmentID);
                    }

                    //取得我直接领导的部门
                    var ObjEmpLoyeeList = this.GetByDepartmetnKeysList(ObjKeyList.ToArray());


                    //取得我间接领导的部门主管
                    ObjDepartmentList = new List <Sys_Department>();
                    ObjDepartmentList = ObjDataContext.CreateQuery <Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.Parent  = " + MyDepartment.DepartmentID).ToList <Sys_Department>();
                    if (ObjDepartmentList.Count > 0)
                    {
                        foreach (var ObjDepartmentManager in ObjDepartmentList)
                        {
                            if (ObjDepartmentManager.DepartmentManager != null && ObjDepartmentManager.DepartmentManager != 0)
                            {
                                ObjEmpLoyeeList.Add(this.GetByID(ObjDepartmentManager.DepartmentManager));
                            }
                        }
                    }
                    return(ObjEmpLoyeeList.Where(C => C.EmployeeID != EmpLoyeeID && C.Status == 0).ToList());
                    //然后计算我的直接领导部门 就是部门主管是我的
                }
                else
                {
                    var MineDepartment = new List <Sys_Department>();

                    //foreach (var ObjDepartment in MyDepartmentList)
                    //{
                    //    MineDepartment.AddRange(ObjDataContext.CreateQuery<Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.SortOrder  = '" + MyDepartment.SortOrder + "'").ToList<Sys_Department>());
                    //}


                    foreach (var ObjDepartment in MyDepartmentList)
                    {
                        ObjDepartmentList.AddRange(ObjDataContext.CreateQuery <Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.SortOrder  Like '%" + MyDepartment.SortOrder + "%'").ToList <Sys_Department>());
                    }


                    foreach (var RemoveItem in MineDepartment)
                    {
                        ObjDepartmentList.Remove(ObjDepartmentList.First(C => C.DepartmentID == RemoveItem.DepartmentID));
                    }


                    //取得部门主管 和我直接领导的部门

                    //部门主管
                    List <int> ObjManagerList = new List <int>();
                    foreach (var Objitem in ObjDepartmentList)
                    {
                        ObjKeyList.Add(Objitem.DepartmentID);
                    }


                    ObjDepartmentList = new List <Sys_Department>();
                    ObjDepartmentList = ObjDataContext.CreateQuery <Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.Parent  =" + MyDepartment.DepartmentID).ToList <Sys_Department>();
                    //取得我直接间接领导的部门
                    var ObjEmpLoyeeList = this.GetByDepartmetnKeysList(ObjKeyList.ToArray());
                    if (ObjDepartmentList.Count > 0)
                    {
                        foreach (var ObjDepartmentManager in ObjDepartmentList)
                        {
                            if (ObjDepartmentManager.DepartmentManager != null && ObjDepartmentManager.DepartmentManager != 0)
                            {
                                var ObjEmpLoyeeListFirst = ObjEmpLoyeeList.FirstOrDefault(C => C.EmployeeID == ObjDepartmentManager.DepartmentManager);
                                if (ObjEmpLoyeeListFirst != null)
                                {
                                    ObjEmpLoyeeList.Remove(ObjEmpLoyeeListFirst);
                                }
                            }
                        }
                    }

                    return(ObjEmpLoyeeList.Where(C => C.EmployeeID != EmpLoyeeID && C.Status == 0).ToList());
                }
                ////猜测是否为部门主管
                //if (ObjDepartment.DepartmentManager == ObjEmpLoyee.EmployeeID)
                //{
                //Department ObjDepartmentBLL=new Department();


                // var DepartmetnList = ObjDataContext.CreateQuery<Sys_Department>("Select VALUE c from HHL_WeddingEntities.Sys_Department as c where c.SortOrder  Like '%" + ObjDepartment.SortOrder + "%'").ToList<Sys_Department>();
            }

            //return new List<Sys_Employee>();
        }
コード例 #35
0
 public CompiledQueryContext(EntityConnection connection)
     : base(connection)
 {
 }
コード例 #36
0
 /// <summary>
 /// Initialize a new Model1Container object.
 /// </summary>
 public Model1Container(EntityConnection connection) : base(connection, "Model1Container")
 {
     OnContextCreated();
 }
コード例 #37
0
 /// <summary>
 /// Initialize a new DataContextModelContainer object.
 /// </summary>
 public DataContextModelContainer(EntityConnection connection) : base(connection, "DataContextModelContainer")
 {
     this.ContextOptions.LazyLoadingEnabled = false;
     OnContextCreated();
 }
コード例 #38
0
 /// <summary>
 /// Initialize a new datesTypesEntities object.
 /// </summary>
 public datesTypesEntities(EntityConnection connection) : base(connection, "datesTypesEntities")
 {
     this.ContextOptions.LazyLoadingEnabled = true;
     OnContextCreated();
 }
コード例 #39
0
 /// <summary>
 /// Initialize a new GtdAppDataContext object.
 /// </summary>
 public GtdAppDataContext(EntityConnection connection) : base(connection, "GtdAppDataContext")
 {
     this.ContextOptions.LazyLoadingEnabled = true;
     OnContextCreated();
 }
コード例 #40
0
 /// <summary>
 /// Initialize a new ModelFirstModel1Container object.
 /// </summary>
 public ModelFirstModel1Container(EntityConnection connection) : base(connection, "ModelFirstModel1Container")
 {
     this.ContextOptions.LazyLoadingEnabled = true;
     OnContextCreated();
 }
コード例 #41
0
 /// <summary>
 /// Initialize a new HRSkillsEntities object.
 /// </summary>
 public HRSkillsEntities(EntityConnection connection) : base(connection, "HRSkillsEntities")
 {
     this.ContextOptions.LazyLoadingEnabled = false;
     OnContextCreated();
 }
コード例 #42
0
        // efects: Executes the current function command in the given transaction and connection context.
        // All server-generated values are added to the generatedValues list. If those values are identifiers, they are
        // also added to the identifierValues dictionary, which associates proxy identifiers for keys in the session
        // with their actual values, permitting fix-up of identifiers across relationships.
        internal override long Execute(UpdateTranslator translator, EntityConnection connection, Dictionary <int, object> identifierValues,
                                       List <KeyValuePair <PropagatorResult, object> > generatedValues)
        {
            // configure command to use the connection and transaction for this session
            m_dbCommand.Transaction = ((null != connection.CurrentTransaction) ? connection.CurrentTransaction.StoreTransaction : null);
            m_dbCommand.Connection  = connection.StoreConnection;
            if (translator.CommandTimeout.HasValue)
            {
                m_dbCommand.CommandTimeout = translator.CommandTimeout.Value;
            }

            // set all identifier inputs (to support propagation of identifier values across relationship
            // boundaries)
            if (null != m_inputIdentifiers)
            {
                foreach (KeyValuePair <int, DbParameter> inputIdentifier in m_inputIdentifiers)
                {
                    object value;
                    if (identifierValues.TryGetValue(inputIdentifier.Key, out value))
                    {
                        // set the actual value for the identifier if it has been produced by some
                        // other command
                        inputIdentifier.Value.Value = value;
                    }
                }
            }

            // Execute the query
            long rowsAffected;

            if (null != m_resultColumns)
            {
                // If there are result columns, read the server gen results
                rowsAffected = 0;
                IBaseList <EdmMember> members = TypeHelpers.GetAllStructuralMembers(this.CurrentValues.StructuralType);
                using (DbDataReader reader = m_dbCommand.ExecuteReader(CommandBehavior.SequentialAccess))
                {
                    // Retrieve only the first row from the first result set
                    if (reader.Read())
                    {
                        rowsAffected++;

                        foreach (var resultColumn in m_resultColumns
                                 .Select(r => new KeyValuePair <int, PropagatorResult>(GetColumnOrdinal(translator, reader, r.Key), r.Value))
                                 .OrderBy(r => r.Key)) // order by column ordinal to avoid breaking SequentialAccess readers
                        {
                            int       columnOrdinal = resultColumn.Key;
                            TypeUsage columnType    = members[resultColumn.Value.RecordOrdinal].TypeUsage;
                            object    value;

                            if (Helper.IsSpatialType(columnType) && !reader.IsDBNull(columnOrdinal))
                            {
                                value = SpatialHelpers.GetSpatialValue(translator.MetadataWorkspace, reader, columnType, columnOrdinal);
                            }
                            else
                            {
                                value = reader.GetValue(columnOrdinal);
                            }

                            // register for back-propagation
                            PropagatorResult result = resultColumn.Value;
                            generatedValues.Add(new KeyValuePair <PropagatorResult, object>(result, value));

                            // register identifier if it exists
                            int identifier = result.Identifier;
                            if (PropagatorResult.NullIdentifier != identifier)
                            {
                                identifierValues.Add(identifier, value);
                            }
                        }
                    }

                    // Consume the current reader (and subsequent result sets) so that any errors
                    // executing the function can be intercepted
                    CommandHelper.ConsumeReader(reader);
                }
            }
            else
            {
                rowsAffected = m_dbCommand.ExecuteNonQuery();
            }

            // if an explicit rows affected parameter exists, use this value instead
            if (null != m_rowsAffectedParameter)
            {
                // by design, negative row counts indicate failure iff. an explicit rows
                // affected parameter is used
                if (DBNull.Value.Equals(m_rowsAffectedParameter.Value))
                {
                    rowsAffected = 0;
                }
                else
                {
                    try
                    {
                        rowsAffected = Convert.ToInt64(m_rowsAffectedParameter.Value, CultureInfo.InvariantCulture);
                    }
                    catch (Exception e)
                    {
                        if (UpdateTranslator.RequiresContext(e))
                        {
                            // wrap the exception
                            throw EntityUtil.Update(System.Data.Entity.Strings.Update_UnableToConvertRowsAffectedParameterToInt32(
                                                        m_rowsAffectedParameter.ParameterName, typeof(int).FullName), e, this.GetStateEntries(translator));
                        }
                        throw;
                    }
                }
            }

            return(rowsAffected);
        }
コード例 #43
0
 public NorthwindObjectContext(EntityConnection connection)
     : base(connection, ContainerName)
 {
     this.ContextOptions.LazyLoadingEnabled = true;
 }